package com.neusoft.controller;

import com.neusoft.base.BaseController;
import com.neusoft.model.UserSearch;
import com.neusoft.po.User;
import com.neusoft.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户请求控制器
 *
 * @author Lucifer
 * @since 2021/5/16 8:02
 */
@RestController
@RequestMapping("/user")
@Api(tags = "消费者用户接口")
public class UserController extends BaseController {

    @Resource
    private UserService userService;

    @PostMapping("/page")
    @ApiOperation("消费者用户集合")
    public Object page(@RequestBody UserSearch userSearch) {
        return userService.page(userSearch);
    }

    @GetMapping
    @ApiOperation("单个用户详细消息")
    @ApiImplicitParam(value = "评论ID", name = "id", required = true)
    public User get(Integer id) {
        return userService.getById(id);
    }

    @PostMapping
    @ApiOperation("单条用户注册")
    public Integer save(@RequestBody User user) {
        return userService.save(user);
    }


}
